<?php
use yii\helpers\Html;

/* @var $this \yii\web\View */
/* @var $content string */
?>

    <header class="main-header">

        <?= Html::a('<span class="logo-mini">APP</span><span class="logo-lg">' . Yii::$app->name . '</span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>

        <nav class="navbar navbar-static-top" role="navigation">

            <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>

            <div class="navbar-custom-menu">

                <ul class="nav navbar-nav">
                    <li><?= Html::a('清空缓存', ['site/clear-cache'], ['data-method' => 'post', 'class' => 'clearAssets']) ?></li>
                    <li><?= Html::a('清空前端资源', ['site/clear-assets'], ['data-method' => 'post', 'class' => 'clearAssets']) ?></li>
                    <li><?= Html::a('<i class="fa  fa-home"></i>', Yii::getAlias('@frontendUrl'), ['target' => '_blank']) ?></li>
                    <!-- User Account: style can be found in dropdown.less -->

                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="user-image"
                                 alt="User Image"/>
                            <span class="hidden-xs"><?= Yii::$app->user->identity->username ?></span>
                        </a>
                        <ul class="dropdown-menu">
                            <!-- Menu Footer-->
                            <li class="user-footer">
                                <div class="pull-left">
                                    <a href="<?= \yii\helpers\Url::to(['admin/update', 'id' => Yii::$app->user->id]) ?>"
                                       class="btn btn-default btn-flat">个人资料</a>
                                </div>
                                <div class="pull-right">
                                    <?= Html::a(
                                        '退出登录',
                                        ['/site/logout'],
                                        ['data-method' => 'post', 'class' => 'btn btn-default btn-flat']
                                    ) ?>
                                </div>
                            </li>
                        </ul>
                    </li>
                    <li><?= Html::a('<i class="fa  fa-sign-out"></i>', ['/site/logout'], ['data-method' => 'post']) ?></li>
                </ul>
            </div>
        </nav>
    </header>
<?php
$script = <<<JS
    $(".clearAssets").click(function() {
        $.post($(this).attr('href'),function(result) {
          alert(result);
        })
        return false;
    });
JS;
$this->registerJs($script);
?>